package com.topcoder.service.studio.contest;

import java.io.Serializable;

/**
 * Represents the ContestResource entity. It holds the attributes resource id,
 * and name. It's mutable and not thread safe.
 * 
 * @author xp
 * 
 */
public class ContestResource implements Serializable {
    /**
     * Represents the resource id attribute of the ContestResource entity. It's
     * set and accessed in the set/get methods. It can be any value. The default
     * value is null.
     */
    private Long resourceId;
    /**
     * Represents the name attribute of the ContestResource entity. It's set and
     * accessed in the set/get methods. It can be any value. The default value
     * is null.
     */
    private String name;

    /**
     * Default constructor.
     */
    public ContestResource() {
    }

    /**
     * Returns the resourceId.
     * 
     * @return the resourceId.
     */
    public Long getResourceId() {
        return resourceId;
    }

    /**
     * Updates the resourceId with the specified value.
     * 
     * @param resourceId
     *            the resourceId to set.
     */
    public void setResourceId(Long resourceId) {
        this.resourceId = resourceId;
    }

    /**
     * Returns the name.
     * 
     * @return the name.
     */
    public String getName() {
        return name;
    }

    /**
     * Updates the name with the specified value.
     * 
     * @param name
     *            the name to set.
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Compares this object with the passed object for equality. Only the id
     * will be compared.
     * 
     * @param obj
     *            the {@code Object} to compare to this one
     * @return true if this object is equal to the other, {@code false} if not
     */
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Contest) {
            return getResourceId() == ((ContestResource) obj).getResourceId();
        }
        return false;
    }

    /**
     * Overrides {@code Object.hashCode()} to provide a hash code consistent
     * with this class's {@link #equals(Object)}} method.
     * 
     * @return a hash code for this {@code Contest}
     */
    @Override
    public int hashCode() {
        return Helper.calculateHash(resourceId);
    }
}
